/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						 spell_icon.h

	$Header: /heroes4/spell_icon.h $

	$NoKeywords: $

 ************************************************************************/

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#include "precompiled.h"
#pragma warning( disable: 4786 )

#include "spell_icon.h"

#include "bitmap_group_cache.h"
#include "bitmap_pool.h"
#include "enum_operations.h"
#include "spell.h"
#include "spell_properties.h"

namespace
{
	static t_bitmap_group_cache k_spell_caches[] =
	{	
		"icons.spells.life.52",
		"icons.spells.order.52",
		"icons.spells.death.52",
		"icons.spells.chaos.52",
		"icons.spells.nature.52"
	};

	static t_bitmap_group_cache k_spell_180_caches[] =
	{
		"icons.spells.life.180",
		"icons.spells.order.180",
		"icons.spells.death.180",
		"icons.spells.chaos.180",
		"icons.spells.nature.180",
	};

	class t_spell_definitions : public std::vector<t_string_pair>
	{
	public:
		t_spell_definitions();
	};

}; // unnamed namespace

t_spell_definitions::t_spell_definitions()
{
	t_spell       spell;
	t_string_pair pair;

	reserve( k_spell_count );
	for (spell = t_spell(0); spell < k_spell_count; enum_incr(spell))
	{
		pair.keyword = get_spell_keyword( spell );
		pair.value = get_spell_alignment( spell );
		push_back( pair );
	}
}

static t_spell_definitions const& get_definitions() 
{
	static t_spell_definitions const definitions;

	return definitions;
}

t_bitmap_layer_ptr get_spell_icon( t_spell spell, int height )
{
	static t_bitmap_pool pool( k_spell_caches, &(*get_definitions().begin()),
		                       get_definitions().size() );
	static t_bitmap_pool pool_180( k_spell_180_caches, &(*get_definitions().begin()),
		                       get_definitions().size() );
	if (height < 100)
		return pool.get( spell );
	return pool_180.get( spell );
}
